package com.xlh.job;

import com.xlh.service.courseTest.PaperAnswerSheetService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 答题卡缓存提交任务
 *
 * @author zhr 2019/3/15
 */
@Component
public class AnswerCacheSaveTask {

    private static Logger logger = LoggerFactory.getLogger(AnswerCacheSaveTask.class);

    @Autowired
    private PaperAnswerSheetService answerSheetService;

    /**
     * 每5分钟执行一次提交
     */
    @Scheduled(cron = "0 0/5 * * * *")
    public void saveTask() {
        try{
            answerSheetService.saveCache();
        } catch (Exception e) {
            logger.error("自动保存错误", e);
        }
    }
}
